home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 526-550 / disk_542 / chemnimate / cmtsource.lzh / uni4.h < prev   
C/C++ Source or Header  |  1991-08-28  |  5KB  |  168 lines

  1. /****************************************************************
  2.  *     universal include for my ChemNiMate program        *
  3.  *                                *
  4.  *structures:                            *
  5.  *    DisplayInfo                        *
  6.  *    ParserInfo                        *
  7.  *                                *
  8.  *                                *
  9.  *==============================================================*
  10.  *uni1    06Apr91    KvGend    created from ch5.c & parser2.c         *
  11.  *uni2  07Apr91 KvGend    added ParserInfo             *
  12.  *uni4    14Jun91    KvGend    removed some errornumbers, some structure*
  13.  *            elements which weren't used anymore     *
  14.  *            removed.                 *
  15.  *            fixed some macros to use (x) instead of x*
  16.  *    28Aug91    KvGend    first release                 *
  17.  *                                 *
  18.  *****************************************************************/
  19.  
  20. #include <stdio.h>
  21.  
  22.  /* calculate real coords on screen (displaymode 0).
  23.   * y+ : to the right.
  24.   * x- : to the front (is put diagonally to show 3d)
  25.   * z+ : upwards.
  26.   */
  27. #define RX(y,x)         (di.mx+(y)-(x)/2)
  28. #define RY(z,x)         (di.my-(z)+(x)/2)
  29.  
  30. #define FULLCRAZY -568932871    /*this is a crazy value, ain't it? */
  31. #define ISNUM(x)   ((( (x)>='0'&&(x)<='9') ||(x)=='-') ? 1 : 0)
  32. #define ABS(x)          ( (x)<0 ? -(x) : (x))
  33.  
  34. #define ARR    array[j]
  35. #define RAD    [0]
  36. #define ADD    [1]
  37. #define HEIGHT    [2]
  38. #define KIND    [3]
  39. #define BIND    [4]
  40. #define XC    [5]
  41. #define YC    [6]
  42. #define ZC    [7]
  43.  
  44.  
  45. #define VWIDTH 340        /* width of viewport */
  46. #define VHEIGHT 256
  47.  
  48. #define PWIDTH 380        /* width of the two bitmaps */
  49. #define PHEIGHT 296
  50. #define PDEPTH    3        /* 3 bitplanes means 8 colors. I think it's enough */
  51.  
  52. /* values of bitmap for sourcebitmap */
  53. #define SWIDTH 320
  54. #define SHEIGHT    96        /* it was only a brush */
  55. #define SDEPTH 3
  56.  
  57. #define LBOR    ((PWIDTH-VWIDTH)/2)
  58. #define UBOR    ((PHEIGHT-VHEIGHT)/2)
  59.  
  60. /* In this structure is information put about the display-system */
  61. struct DisplayInfo
  62. {
  63.   int mx, my;            /* what is the centre of the screen? */
  64.   int angle, dangle;        /* angle, delta angle (how turn around?)*/
  65.   char modes;            /* draw lines/balls ? */
  66.   int whichone;            /* which playfield is active at the moment?*/
  67. };
  68.  
  69. #define VALUESMAX 8        /* maximum number of values in one line */
  70. #define MXNUMB 64        /* maximum number of items in memory */
  71.  
  72. #define LINES 32
  73. #define BALLS 64
  74.  
  75. /* In this structure is information put about the parsing */
  76. struct ParserInfo
  77. {
  78.   int datanr;            /* which should next data-line be placed in ?*/
  79.   int linenr;            /* current linenr in script file */
  80.   int valnr;            /* number of values in current line */
  81.   int error;            /* if an error occured, its number is here
  82.                  * otherwise it will be -1 */
  83.   int skip;            /* should a line be skipped? */
  84.   int I;            /* some easy variables */
  85.   int J;
  86. };
  87.  
  88.  
  89. #define ON    91        /* it doesn't matter WHAT these values are*/
  90. #define OFF    97        /* as long as they're different from each other*/
  91.  
  92. #define USEPI   -1
  93.  
  94. #define INFINITYMAX 250
  95.  
  96. /***********************the error-numbers *****/
  97. #define NOTNUMBER_ERR    0
  98. #define EDWD_ERR    1
  99. #define VAL_ERR        2
  100. #define ERWR_ERR    3
  101. #define DATA_ERR    4
  102. #define HEADACHE_ERR    5
  103. #define TOOFEW_ERR    6
  104. #define TOOMUCH_ERR    7
  105. #define OUTSCREEN_ERR    8
  106. #define DIVISION_ERR    9    /*errors of evalexp*/
  107. #define ITTAKESTWO_ERR    10
  108. #define PARENTH_ERR    11
  109. #define NOVAR_ERR    12    /*variables*/
  110. #define VAREND_ERR    13
  111. #define INFINITY_ERR    14
  112. #define NOSKIP_ERR    15
  113. #define DATAEXPR_ERR    16
  114.  
  115. #ifdef PARSER
  116. char *errtxt[] =        /* the errors*/
  117. {                /* all lines end in \0 because they aren't equal in length*/
  118.   "# WARNING: NOT RIGHT NUMBER OF VALUES\0",
  119.   "## EndData WITHOUT Data\0",
  120.   "## INCORRECT VALUE(S) \0",
  121.   "## EndRepeat/Until WITHOUT Repeat/Loop\0",
  122.   "# WARNING: MORE / LESS THAN 5 data VALUES\0",
  123.   "## SYNTAX ERROR\0",
  124.   "## NEEDED # , BUT GOT ONLY # VALUES\0",    /* #1: 10, #2: 27 */
  125.   "# WARNING : MORE THAN REQUIRED # VALUES\0",    /* #1: 31 */
  126.   "# WARNING : ONE OF BALLS GOT OUT SCREEN\0",
  127.   "## EXPRESSION: DIVISION BY ZERO \0",
  128.   "## EXPRESSION: 2 VALUES AND 1 OF: +- * /\0",
  129.   "## EXPRESSION: UNEQUAL NUMBER OF [ AND ]\0",
  130.   "## NOT A KNOWN VARIABLE \0",
  131.   "## VARIABLE NOT TERMINATED BY '#'\0",
  132.   "### until : INFINITY ERROR\0",
  133.   "## EndSkip WITHOUT Skip\0",
  134.   "#### EXPRESSION IN A DATA LINE\0"
  135. };
  136. #else
  137. extern char *errtxt[];        /*for other files than parser.c */
  138. #endif
  139.  
  140.  
  141. /* the amiga-specific stuff */
  142. #ifdef AMIGA
  143. #define RP        &rastport
  144. #define BM        bitmap
  145. #define SBM        &sourcebitmap
  146. #define LINETO(x,y)     Draw(RP,x,y)
  147. #define MOVE(x,y)       Move(RP,x,y)
  148. #define COLOR(x)        SetAPen(RP,x)
  149. #define TEXT(s)        Text(RP,s,strlen(s))
  150. #define WAITFRAME    WaitTOF
  151. #endif /* def AMIGA */
  152.  
  153.  
  154. /* the defines for my stack-routine: */
  155.  
  156. #define ST_INIT 1
  157. #define ST_PUSH 2
  158. #define ST_POP    3
  159. #define ST_QUIT    4
  160. #define ST_NOST -1
  161. #define STMAX    10
  162.  
  163. #define ST_REPEAT    0x02    /*stack was called from repeat*/
  164. #define ST_LOOP        0x03
  165. #define ST_GOSUB    0x04    /*stack was called from gosub */
  166.  
  167. /* end-of-file */
  168.